<?php
/*
* @file processing the ajax chat
*
* @author: Selver.Ding
*/
if (!function_exists('add_action'))
  {
      require_once("../../../../wp-config.php");
  }
    $current_info=wp_get_current_user();

    $current_id=$current_info->id;

  $sql="select * from wp_users where id='".$current_id."' ";

  $r=$wpdb->get_results($sql);
  $r=$r[0];
  $channel_hide=$r->channel_hide;

  $sql="update `wp_users` set `channel_hide`=-1 where id='".$current_id."'";

  $wpdb->query($sql);

?>
/**
 * in_array for javascript
 *
 * @arguments
 *   arr - array to be searched
 *   value - item to search for
 *
 * @author Joshua Gross
 * @return true if 'value' is found in 'arr', false if it is not.
 **/
function inArray(arr, value) {
   var i;
   for (var group in arr) {
     // Matches identical (===), not just similar (==).
      for(i=0; i<arr[group].length; i++) {
         if(arr[group][i] === value)
            return true;
      }
   }
   return false;
};
Array.prototype.inArray = function(search_term) { // Adds inArray to all arrays
   var i = this.length;
   if (i > 0) {
      while(i--) {
         if (this[i].id === search_term) {
		 	this.index = i;
            return true;
         }
      }
   }
   return false;
}
var request = window.setInterval(ajax,3000);
var tab_ = 1;
var tab_i = 99;
var posx=0;
var posy=0;
var oDiv;
var nomessage_alert = 'There are no messages yet today. To show older conversations use the calendar to choose a date.';
current_sender_id = <?php $current_info=wp_get_current_user();$u_id = $current_info->data->ID;if($u_id){echo $u_id;}else{echo 0;} ?>;
var scroll_height=0;
var channel_hide="<?php echo $channel_hide ?>";
jQuery(window).scroll(function(){
    if  (jQuery(window).scrollTop() == (jQuery(document).height() - jQuery(window).height())){
        lastPostFunc();
    }
});
function tab(tag){
  tab_ = tag;
  if(tag == 1)
  {
  	ajaxGetContent('init');
	tab_i = 99;
	jQuery("#sidebar_Messages").show();
	jQuery("#list").show();
    jQuery("#side_top").hide();
    init_calendar();
    jQuery("#chat_room_id").attr("disabled", false);
  }
  else if(tag == 2)
  {
  	ajaxGetContent('init_private');
	tab_i = 99;
	jQuery("#sidebar_Messages").hide();
	jQuery("#list").hide();
    jQuery("#side_top").show();
    init_calendar();
    jQuery("#chat_room_id").attr("disabled", false);
  }
  for(i=1; i <3; i++){
     if (i==tag) {
         document.getElementById("tag"+i).className="tag-selected";
         document.getElementById("box"+i).style.display="block";
     }else{
         document.getElementById("tag"+i).className="";
         document.getElementById("box"+i).style.display="none";
	 }
  }
}
function init_calendar()
{
    var m='';
    var y='';
    var o_url="<?php bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/calendar.php";

        jQuery.get(o_url,{mon:m,year:y},function(data){jq_ajax_data(data)})
    var current_time = <?php echo mktime(0,0,0,date("m"),date("d"),date("Y"));?>;
        document.getElementById("r_day").setAttribute("value",current_time);
        document.getElementById("r_page").setAttribute("value",1);
}

function generate_channel_hide(c)
{
    channel_hide=c.split(",");
}
jQuery(document).ready(function(){
    generate_channel_hide(channel_hide);
    if(jQuery('table tr:last-child td:first-child').html()=='')
    {
        jQuery('table tr:last-child').remove();
    }

    document.onmousemove = mouseMove;
	ajaxGetContent('init');
	ajaxGetContent('init_private');
	jQuery("#chat_room_id").attr('value','');
	jQuery("#receiver_id").attr('value','');

	jQuery("[name='room']").each(function(i){
		if(jQuery(this).attr("checked")!=true)
		{
			jQuery(this).attr("checked","checked");
		}
	});
    // Make sure the channel uncheck
    for(i=0;i<channel_hide.length;i++)
    {
        //alert(document.getElementById("room_"+channel_hide[i]));
        if(document.getElementById("room_"+channel_hide[i])!=null)
        {
            document.getElementById("room_"+channel_hide[i]).checked=false;
        }
    }

    jQuery("#chat_room_id").attr("disabled", false);
	jQuery("#receiver_id").attr("disabled", false);
    scroll_height=get_scroll_height();

	if( current_sender_id == 0)
	{
        jQuery("#sender_form>textarea").val('Choose session from dropdown menu before writing.');
        jQuery("#private_form>textarea").val('Choose participant from dropdown before writing.');
		jQuery("#sender_form>textarea").attr("disabled", true);
		jQuery("#private_form>textarea").attr("disabled", true);

	}
	document.body.onkeypress = function(e){
		var J = window.event || e;
		if(J.keyCode == 13){
			if(!J.shiftKey)
			{
				if(tab_ == 1)
				{
					jq_insert_message();
					//clear the content in the textarea
					jQuery('#message').val('');
					return false;
				}
				else if(tab_ == 2)
				{
					private_ajax_chat();
					//clear the content in the textarea
					jQuery('#private_message').val('');
					return false;
				}
				else
				{
					return false;
				}
			}
			if(tab_ == 1)
			{
				//document.getElementById("message").value += "\n";
			}
			else if(tab_ == 2)
			{
				//document.getElementById("private_message").value += "\n";
			}
		}
	}
	textarea_enable(tab_,tab_i,current_sender_id);
	jQuery("#chat_room_id").change(function(){
		if(jQuery("#chat_room_id").attr('value') != ''){
        	checked_room_id = jQuery("#chat_room_id").attr('value');
			jQuery('#alert_info').html('');
            jQuery('#room_'+checked_room_id).attr('checked','checked');
            hideMess(document.getElementById("room_"+checked_room_id));
			//today = <?php echo mktime(0,0,0,date("m"),date("d"),date("Y"));?>;
			//retrieve_data_record_(today);
		}
     	textarea_enable(tab_,tab_i,current_sender_id);
	});
	jQuery("#receiver_id").change(function(){
		if(jQuery("#receiver_id").attr('value') != ''){
			jQuery('#user_sel_info').html('');
		}
		reply(jQuery("#receiver_id").attr('value'));
		textarea_enable(tab_,tab_i,current_sender_id);
    var current_time = <?php echo mktime(0,0,0,date("m"),date("d"),date("Y"));?>;
        document.getElementById("r_day").setAttribute("value",current_time);
        document.getElementById("r_page").setAttribute("value",1);
	});
	uid = jQuery('#reply_id').attr('value');
	if(uid != -1){
		talkTo(uid);
	}
	var view_tab = jQuery("#view_tab").attr('value');
	if(view_tab != '0'){
		tab(view_tab);
	}
});

function ajax()
{
	if(tab_ == 1&&tab_i == 99)
	{
		//session ajax
		ajaxGetContent();
	}
	else if(tab_ == 2&&tab_i == 99)
	{
		//private ajax
		ajaxGetContent('private');
	}

}

function textarea_enable(tab_,tab_i,current_sender_id,day)
{
	var current_time = <?php echo mktime(0,0,0,date("m"),date("d"),date("Y"));?>;
	day = arguments[3] ? arguments[3] : current_time;
	var receiver_id = jQuery("#receiver_id").attr("value");
	var chat_room_id = jQuery("#chat_room_id").attr("value");
	//alert("tab_="+tab_+","+"tab_i="+tab_i+","+"current_sender_id="+","+current_sender_id);
	if(tab_ == 1 && tab_i == 0 || current_sender_id == 0 || chat_room_id == '')
	{
        jQuery('#message').val('');
		if(day == current_time){
        jQuery("#sender_form>textarea").val('Choose session from dropdown menu before writing.');
		}
		else{
		jQuery("#sender_form>textarea").val('Please retrieve to today on calendar and Choose session from dropdown menu before writing.');
		}
		jQuery("#sender_form>textarea").attr("disabled", true);

		if(document.getElementsByTagName("textarea").item(0) != null){
			document.getElementsByTagName("textarea").item(0).style.backgroundColor="#ECE9D8";
			document.getElementsByTagName("textarea").item(0).style.overflow="auto";
		}
	}
	if(tab_ == 2 && tab_i == 0 || current_sender_id == 0 || receiver_id == '')
	{
        jQuery('#private_message').val('');
        jQuery("#private_form>textarea").val('Choose participant from dropdown before writing.');
		jQuery("#private_form>textarea").attr("disabled", true);

		if(document.getElementsByTagName("textarea").item(1) != null){
			document.getElementsByTagName("textarea").item(1).style.backgroundColor="#ECE9D8";
			document.getElementsByTagName("textarea").item(1).style.overflow="auto";
		}
	}
	if(tab_ == 1 && tab_i == 99)
	{
		//session ajax
		if(current_sender_id != 0 && chat_room_id != '')
		{
			jQuery('#message').focus();
			jQuery("#sender_form>textarea").attr("disabled", false);
            jQuery("#sender_form>textarea").val('');
			if(document.getElementsByTagName("textarea").item(0) != null){
				document.getElementsByTagName("textarea").item(0).style.backgroundColor="#fff";
				document.getElementsByTagName("textarea").item(0).style.overflow="auto";
			}
		}
	}
	else if(tab_ == 2&&tab_i == 99)
	{
		//private ajax
		if(current_sender_id != 0 && receiver_id != '')
		{
			jQuery('#private_message').focus();
			jQuery("#private_form>textarea").attr("disabled", false);
            jQuery("#private_form>textarea").val('');
			if(document.getElementsByTagName("textarea").item(1) != null){
				document.getElementsByTagName("textarea").item(1).style.backgroundColor="#fff";
				document.getElementsByTagName("textarea").item(1).style.overflow="auto";
			}
		}
	}
}

function hideMess(obj)
{
    if(jQuery("input[id=room_"+obj.alt+"]").attr("checked")!=true)
	{
        record_hide_channel(obj.alt)
	}
	jQuery('#messageContent>li').each(function(){
		if(jQuery(this).attr('alt') == obj.alt)
		{
			if(jQuery("input[id=room_"+obj.alt+"]").attr("checked")!=true)
			{
				jQuery(this).hide();
			}
			else
			{
				jQuery(this).show();
			}
		}
	});
}
function record_hide_channel(record_channel_id)
{
    var url="<?php echo bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/ajaxchat_content.php";
    jQuery.get(url+"?random="+(new Date()).getTime(),{record_channel_id:record_channel_id},function(){});

}

<?php
$options = get_option("live_chat");
$profiler_page_id = $options['profiler_page_id'];
$sql = "SELECT `post_name` FROM `wp_posts` WHERE `post_status`='publish' AND `ID`=$profiler_page_id";
$profiler_page_name = $wpdb->get_results($sql,ARRAY_A);
$profiler_page_post_name = $profiler_page_name[0]['post_name'];
$perma = get_settings('permalink_structure');
if (!$perma) {
	$profile_page_url = get_bloginfo('wpurl')."/?page_id=$profiler_page_id&";
}
else {
	$profile_page_url = get_bloginfo('wpurl')."/$profiler_page_post_name/";
}

?>
function getUserProfiler(username)
{
	var profile_username = username.replace(' ','-');
	return "<?php echo $profile_page_url; ?>"+"user="+profile_username ;
}
function getUserProfiler_perma(profiler)
{
	return "<?php echo $profile_page_url; ?>"+profiler+"/" ;
}
function getUsername(u_id,username,profiler,isanony){
	if(isanony == 1)
	{
		return '';
	}
	else
	{
		//return "<a href='javascript:void(0);' rel='"+u_id+"' onclick='retrieve_user_info(event,this);return false'>"+username+"</a>&nbsp";
		//if not use permalink
		//return "<a href='"+getUserProfiler(username)+"'>"+username+"</a>&nbsp";
		//if use permalink
		return "<a href='"+getUserProfiler_perma(profiler)+"'>"+username+"</a>&nbsp";
	}
}
function talkTo(uid)
{
	tab(2);
	reply(uid);
}
//var iconurl= "<?php echo get_avatar( get_the_author_id(), $size = '46', $default = '<path_to_url>' ); ?>";
//var iconurl="<?php echo get_bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/style/img/pic.gif";
var loader="<?php echo get_bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/style/img/ajax-loader.gif";
function ajaxGetContent(operation){
    var url="<?php echo bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/ajaxchat_content.php";
	var xlurl="<?php echo get_bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/style/img/x1.gif";
	var operation = arguments[0] ? arguments[0] : '' ;
	//alert(operation);
	if(operation == 'init')
	{
		jQuery.ajax({
			type: 'get',
			url: url+"?random="+(new Date()).getTime(),
			data: {operation : operation},
			beforeSend:function(){
				jQuery('#messageContent').html("<img src='"+loader+"'/>");
			},
			success:function(response){
				//alert('init');
				var searchValue = document.location.hash == "" ? "#" : document.location.hash;
				json = eval('('+response+')');
				var output = '';
                var dis='';
				if(json != null)
				{
					for(i=0;i < json.length;i++)
					{
						var rating_html = '';
						rating_num = (json[i].rating < 6) ? json[i].rating : 5 ;
						for(j=0;j < rating_num;j++)
						{
							rating_html += "<img src='"+xlurl+"' width='14' height='14' />";
						}
                        if(jQuery("input[id=room_"+json[i].room_id+"]").attr("checked")!=true)
                        {
                            dis="none";
                        }else
                        {
                            dis='';
                        }

						output += "<li id='"+json[i].id+"' alt='"+json[i].room_id+"' style='background-color:#"+json[i].color+";display:"+dis+"'><div class='user'>"+json[i].icon+"<div class='text'>";
                        output +="<a name='m_"+json[i].id+"'></a>";
						output += getUsername(json[i].sender_id,json[i].username,json[i].profiler,json[i].anonymous);
						output += "<span>"+json[i].text+"</span><div class='info'><p class='pic' alt='"+json[i].rating+"' onmouseover='ajax_rating_count(event,this)' onmouseout='hidealt()'>"+rating_html+"</p><p class='clock'>"+json[i].time+"</p>";
						if(current_sender_id != 0)
						{
							if(json[i].sender_id != current_sender_id )
							{
								output += "<p class='important'><a href='javascript:void(0);' onclick='addrating(this);return false;'>Important to me</a></p>";
							}
						}
						output += "</div></div><br class='clear' /></div></li>";
					}
				}
				else
				{
					output = '<li style="background:#fff;">'+nomessage_alert+'</li>';
				}
				jQuery('#messageContent').html(output);
				self.location.href = searchValue;
			}
		});
	}
	else if(operation == 'init_private')
	{
		var receiver_id = jQuery("#receiver_id").attr("value");
		jQuery.ajax({
			type: 'get',
			url: url+"?random="+(new Date()).getTime(),
			data: {operation : operation,sender : receiver_id},
			beforeSend:function(){
				jQuery('#private_messageContent').html("<img src='"+loader+"'/>");
			},
			success:function(response){
				//alert('init');
				json = eval('('+response+')');
				var output = '';
				if(json != null)
				{
					for(i=0;i < json.length;i++)
					{
						output += "<li id='"+json[i].id+"'><div class='user'><a href='#' onclick='reply(this.rel);return false;' rel='"+json[i].sender_id+"'>"+json[i].icon+"</a><div class='text'>";
						output += getUsername(json[i].sender_id,json[i].username,json[i].profiler,json[i].anonymous);
						output += "<span>"+json[i].text+"</span><div class='info'><p class='clock'>"+json[i].time+"</p>";
						if(json[i].sender_id != current_sender_id)
						{
						output += "<p class='important'><a href='javascript:void(0);' onclick='reply(this.rel);return false;' rel='"+json[i].sender_id+"'>reply to me</a></p>";
						}
						output += "</div></div><br class='clear' /></div></li>";
					}
				}
				else
				{
					output = '<li style="background:#fff;">'+nomessage_alert+'</li>';
				}
				jQuery('#private_messageContent').html(output);
			}
		});
		//alert('init_private');
	}
	else if (operation == 'private')
	{
		/*inserted_mess_id = new Array();
		if(tab_ == 2)
		{
			if(jQuery('#private_messageContent>li').html() != null){
				jQuery('#private_messageContent li').each(function(i){
					if(this.id != 'undefined'){
						inserted_mess_id[i] = this.id;
					}
				});
			}
		}*/
		jQuery.getJSON(url+"?random="+(new Date()).getTime(),{operation : operation},function(json){
			var output = '';
			if(json != null)
			{
				/*if(inserted_mess_id.length != 0)
				{
					for(i=0;i<inserted_mess_id.length;i++)
					{
						if(json.inArray(inserted_mess_id[i]))
						{
							json.splice(json.index,1);
						}
					}
				}*/
				if(jQuery('#private_messageContent>li').html() == nomessage_alert)
				{
					jQuery('#private_messageContent').html('');
				}
				for(i=0;i < json.length;i++)
				{
					output = "<div class='user'><a href='#' onclick='reply(this.rel);return false;' rel='"+json[i].sender_id+"'>"+json[i].icon+"</a><div class='text'>";
					output += getUsername(json[i].sender_id,json[i].username,json[i].profiler,json[i].anonymous);
					output += "<span>"+json[i].text+"</span><div class='info'><p class='clock'>"+json[i].time+"</p><p class='important'><a href='javascript:void(0);' onclick='reply(this.rel);return false;' rel='"+json[i].sender_id+"'>reply to me</a></p></div></div><br class='clear' /></div>";
					temp_html=jQuery("<li id='"+json[i].id+"'></li>");
					temp_html.html(output);


                    o_id=json[i].id;
                    if(jQuery('#private_messageContent').children('#'+o_id).html()==null)
                    {
                        if(jQuery('#private_messageContent>li').html()!=null)
                        {
                          temp_html.insertBefore(jQuery('#private_messageContent>li')[0]);
                        }else
                        {
                          jQuery('#private_messageContent').append(temp_html);
                        }
                    }
				}
			}
			else
			{
				return false;
			}
		});
	}
	else
	{
		var room_id = new Array();
		var chatroom = '';
		jQuery("[name='room'][@checked]").each(function(i){
			room_id[i] = jQuery(this).attr('alt');
		});
		if(room_id != '')
		{
			for(j=0;j<room_id.length-1;j++)
			{
				chatroom += room_id[j]+',';
			}
			chatroom += room_id[room_id.length-1];
		}
		/*inserted_mess_id = new Array();
		if(tab_ == 1)
		{
			if(jQuery('#messageContent>li').html() != null){
				jQuery('#messageContent li').each(function(i){
					if(this.id != 'undefined'){
						inserted_mess_id[i] = this.id;
					}
				});
			}
		}*/
		jQuery.getJSON(url+"?random="+(new Date()).getTime(),{chatroom:chatroom},function(json){
			var output = '';
			if(json != null)
			{
				/*
					if(inserted_mess_id.length != 0)
					{
						for(i=0;i<inserted_mess_id.length;i++)
						{
							if(json.inArray(inserted_mess_id[i]))
							{
								json.splice(json.index,1);
							}
						}
					}
				*/
				if(jQuery('#messageContent>li').html() == nomessage_alert)
				{
					jQuery('#messageContent').html('');
				}
				for(i=0;i < json.length;i++)
				{

					var rating_html = '';
					rating_num = (json[i].rating < 6) ? json[i].rating : 5 ;
					for(j=0;j < rating_num ;j++)
					{
						rating_html += "<img src='"+xlurl+"' width='14' height='14' />";
					}
					output = "<div class='user'>"+json[i].icon+"<div class='text'>";
					output += getUsername(json[i].sender_id,json[i].username,json[i].profiler,json[i].anonymous);
					output += "<span>"+json[i].text+"</span><div class='info'><p class='pic' alt='"+json[i].rating+"' onmouseover='ajax_rating_count(event,this)' onmouseout='hidealt()'>"+rating_html+"</p><p class='clock'>"+json[i].time+"</p><p class='important'><a href='javascript:void(0);;' onclick='addrating(this);return false;'>Important to me</a></p></div></div><br class='clear' /></div>";
					temp_html=jQuery("<li id='"+json[i].id+"' alt='"+json[i].room_id+"' ></li>").css("background-color","#"+json[i].color);
					temp_html.html(output);

                    o_id=json[i].id;


                    if(jQuery('#messageContent').children('#'+o_id).html()==null)
                    {
                        if(jQuery('#messageContent>li').html()!=null)
                        {
                          temp_html.insertBefore(jQuery('#messageContent>li')[0]);
                        }else
                        {
                          jQuery('#messageContent').append(temp_html);
                        }
                    }
				}
			}
			else
			{
				return false;
			}
		});
	}
}

function addrating(obj)
{
    obj.parentNode.previousSibling.previousSibling.setAttribute("alt",Number(obj.parentNode.previousSibling.previousSibling.getAttribute("alt"))+1);
	id = obj.parentNode.parentNode.parentNode.parentNode.parentNode.id;
	x_img='<?php echo get_bloginfo('wpurl')?>/wp-content/plugins/wp-livechat/style/img/x1.gif';
	jQuery.ajax({
            type:'get',
            data: {r_id:id,operation:'rating'},
            url:"<?php echo get_bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/ajaxchat_content.php"+"?random="+(new Date()).getTime(),
            success:function(msg){
				if(msg=='Success')
				{
					if(jQuery("#"+id+">.user>.text>.info>.pic>img").length < 5)
					{
						//alert('add');
						jQuery("#"+id+">.user>.text>.info>.pic").append("<img src='"+x_img+"' width='14' height='14' />");
					}
					else
					{
						return false;
					}
				}
            }
        });
}

function reply(uid)
{
	if(uid != '')
    {
        jQuery("#receiver_id").attr("value",uid);
        today = <?php echo mktime(0,0,0,date("m"),date("d"),date("Y"));?>;
        retrieve_data_record_(today,'#');
        jQuery('.today>a').click();
        jQuery('#user_sel_info').html('');
    }
    else
    {
    	jQuery('#private_messageContent').html('<li></li>');
    	return false;
    }
}
<?php
/*
* jquery ajax dom insert
*
* @author evan.chen
*/
?>


// Ajax Update the message block
function jq_pop_content(response){

}

// Channel Ajax insert new message
function jq_insert_message(){

    if(!validate_sel_channel())
    {
        return false;
    }
	if(jQuery('#messageContent>li').html() == nomessage_alert)
	{
		jQuery('#messageContent').html('');
	}
    if(trim(jQuery('#message').val())=='')
    {
        return false;
    }else{
		checked_id = jQuery('#chat_room_id').attr('value');
		jQuery.ajax({
			type:'post',
			data: jQuery('#sender_form').serialize(),
			url:"<?php echo get_bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/ajaxchat_content.php",
			success:function(data){
				jq_dom_insert(data);
			}
		});
        jQuery('#message').val('');
		jQuery('#room_'+checked_id).attr('checked','checked');
		hideMess(document.getElementById("room_"+checked_id));
        //jQuery('#room_'+checked_id).attr('checked') == 'checked';
    }
}

// Channel Dom insert the message
function jq_dom_insert(response){
 	// if response is null return
    if(response=='Error')
    {
        return;
    }
    // Chang the json string to an Object
    oMessage=eval('('+response+')');

    if(Number(oMessage.anonymous)==1)
    {
		var iconurl = "<?php echo get_bloginfo('wpurl')."/wp-content/plugins/wp-livechat/style/img/pic.gif"; ?>";
        oMessage.u_img = '<img src="'+iconurl+'" width="46" height="46"/>';
    }

    x_img='<?php echo get_bloginfo('wpurl')?>/wp-content/plugins/wp-livechat/style/img/x1.gif';


    mes_content='<div class="user">';
    mes_content+= oMessage.u_img;//'<img src="'+oMessage.u_img+'" width="46" height="46"/>';
    mes_content+='<div class="text">';
    //mes_content+='<a href="#" rel='+oMessage.u_id+' onclick="retrieve_user_info(event,this);return false" onmouseout="hidden_user_info();return false">'+oMessage.u_name+'</a>';
    mes_content+="<a href='"+getUserProfiler_perma(oMessage.profiler)+"'>"+oMessage.u_name+"</a>&nbsp";
    mes_content+='<span> '+oMessage.content+'</span>';

    mes_content+='<div class="info">';
    mes_content+='<p class="pic"></p><p class="clock">'+oMessage.time+'</p>';
    //mes_content+='<p class="important"><a href='#' onclick='addrating(this);return false;'>Important to me</a></p>';
    mes_content+='</div>';
    mes_content+='<div class="clear"></div>';
    mes_content+='</div>';

	var room_id = new Array();
	jQuery("[name='room'][@checked]").each(function(i){
		room_id[i] = jQuery(this).attr('alt');
	});
    ;
    //jQuery('#room_'+oMessage.channel).attr('checked') != 'checked'
	if(in_array(oMessage.channel,room_id))
	{
		//alert(oMessage.channel+"in"+room_id);
		my_li=jQuery('<li alt="'+oMessage.channel+'" id="'+oMessage.channel+'"></li>').css("background-color","#"+oMessage.color);
	}
	else
	{
		//alert('hide');
		my_li=jQuery('<li alt="'+oMessage.channel+'" id="'+oMessage.channel+'"></li>').css({"background-color":"#"+oMessage.color,"display":"none"});
	}
    my_li.html(mes_content);
	if(jQuery('#messageContent>li').html() != null)
	{
		my_li.insertBefore(jQuery('#messageContent>li')[0]);
	}
	else
	{
		jQuery('#messageContent').append(my_li);
	}
}
/*
* Retrieve the user information
*/
function retrieve_user_info(event,obj)
{
    //alert(obj.getAttribute("style"));
    //var tip_html=jQuery('tip').html('111111111111111');
    var style_pos=getPosition(obj);
    var u_id=obj.getAttribute("rel");
    var _url="<?php echo bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/userinfo.php";


    jQuery.getJSON(_url,{u_id:u_id},function(json){
    info_ul='<div><span style="float:right;position:relative;top:-13px;right:-10px;cursor:pointer;" onclick="'+'closeE()'+'"> × </span></div>';
    info_ul+="<ul>";
    info_ul+='<li style="line-height:20px;">'+"Nick Name:"+json[0].display_name+"</li>";
    info_ul+='<li style="line-height:20px;">'+"Email:"+json[0].user_email+"</li>";
    info_ul+='<li style="line-height:20px;">'+"Home Page:"+json[0].user_url+"</li>";
    info_ul+='<li style="line-height:20px;">'+"Register Time:"+json[0].user_registered+"</li>";
    info_ul+="</ul>";
    info_ul+="</div>";


    if(checkBrowser()==2)
    {
        scroll_height=document.documentElement.scrollTop;
    }

    document.getElementById("u_info").innerHTML=''+info_ul+'';

    document.getElementById("u_info").style.visibility="visible";
    document.getElementById("u_info").style.display = "";
    ShowPos(obj);
    //document.getElementById("u_info").style.left ="300px";
    //document.getElementById("u_info").style.top ="400px";
    })
}
function closeE()
{
    document.getElementById("u_info").style.display="none";
}
/*
* Hidden the user information
*/
function hidden_user_info(event,obj)
{

}

function in_array(v,a){
   for(key in a){
      if(a[key]==v) {return true};
   }
   return false;
}
/*
* private chat Ajax request
*/
function private_ajax_chat()
{
    if(!validate_sel_user())
    {
        return false;
    }
	if(jQuery('#private_messageContent>li').html() == nomessage_alert)
	{
		jQuery('#private_messageContent').html('');
	}
    if(trim(jQuery('#private_message').val())==''){
        return false;
    }
	else{
			jQuery.ajax({
				type:'post',
				data:jQuery('#private_form').serialize(),
				url:"<?php echo get_bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/ajaxchat_content.php",
				success:function(data){
					private_dom_insert(data);
				}
			});
        jQuery('#private_message').val('');
    }
}

/*
* Private chat dom insert
*/
function private_dom_insert(response)
{
    if(response=='Error')
    {
        return;
    }

    var pMessage=eval('('+response+')');

    var pContent='<div class="user">';
    pContent+= pMessage.u_img;//'<img src="'+pMessage.u_img+'" width="46" height="46">';
    pContent+='<div class="text">';
    //pContent+='<a href="#" rel='+pMessage.u_id+' onclick="retrieve_user_info(event,this);return false" onmouseout="hidden_user_info();return false">'+pMessage.u_name+'</a>';
	pContent+="<a href='"+getUserProfiler_perma(pMessage.profiler)+"'>"+pMessage.u_name+"</a>&nbsp";
    pContent+='&nbsp<span>'+pMessage.content+'</span>';
    pContent+='<div class="info">';
    pContent+='<p class="clock">'+pMessage.time+'</p>';
    //pContent+='<p class="important">replay to me</p>';
    pContent+='</div>';
    pContent+='<div class="clear"></div>';
    pContent+='</div>';
    pContent+='</div>';

    var private_li=jQuery('<li></li>');
    private_li.html(pContent);

    if(jQuery('#private_messageContent>li').html()!=null)
    {
       private_li.insertBefore(jQuery('#private_messageContent li')[0]);
    }else{
        jQuery('#private_messageContent').append(private_li);
    }

}
/*
* chang the clendar when you click > on calendar
*/
function js_data_change(mon_year)
{
    var strs=new Array();
    var m='';
    var y='';
    strs=mon_year.split("&");

    m=strs[0].split("=");
    m=m[1];
    y=strs[1].split("=");
    y=y[1];

    var o_url="<?php bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/calendar.php";

    if(m!=''&&y!='')
    {
        jQuery.get(o_url,{mon:m,year:y},function(data){jq_ajax_data(data)})
    }

}


function jq_ajax_data(data)
{
    jQuery('#m_calendar').html(data);
    if(jQuery('table tr:last-child td:first-child').html()=='')
    {
        jQuery('table tr:last-child').remove();
    }
}


function retrieve_data_record(obj)
{
    document.getElementById('r_day').setAttribute("value",obj.rel);
    document.getElementById('r_page').setAttribute("value",2);
    <?php
	$d = getdate(time());
    $year=$d['year'];
    $month=$d['mon'];
    $day=$d['mday'];
	?>
	var current_time = "<?php echo mktime(0,0,0,$month,$day,$year); ?>";

    jQuery('#m_calendar .calendar_tr td').css("background-color","#F7F7F7");
	jQuery('#m_calendar .calendar_tr td a').css("color","#000");
    //alert(jQuery('#m_calendar .calendar_tr td'));
    var day=obj.rel;
    obj.parentNode.style.background="#0063CE";
    obj.style.color="#FFFFFF";
	//obj.setAttribute("style","color:write");

    if(obj.rel==current_time)
    {
        obj.parentNode.style.background="#0063CE";
    }else{
        jQuery('.today').css("background-color","#ccc");
    }
	retrieve_data_record_(obj.rel,obj.href);
}

function retrieve_message(obj)
{
	var current_time = "<?php echo mktime(0,0,0,$month,$day,$year); ?>";
	var o_url="<?php bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/calendar.php";
	retrieve_data_record_(obj.rel,obj.href);
	jQuery.get(o_url,{c_get_time:obj.rel},function(data){jq_ajax_data(data)
    	jQuery('#m_calendar .calendar_tr td').css("background-color","#F7F7F7");
		jQuery('#m_calendar .calendar_tr td a').css("color","#000");
		jQuery("#m_calendar table tbody tr td a[rel="+obj.rel+"]").parent().css("background-color","#0063CE");
		jQuery("#m_calendar table tbody tr td a[rel="+obj.rel+"]").css("color","#fff");
    	if(obj.rel!=current_time)
    	{
        	jQuery('.today').css("background-color","#ccc");
    	}
	});
}

function retrieve_data_record_(day,href)
{
	jQuery("[name='room']").each(function(i){
		if(jQuery(this).attr("checked")!=true)
		{
			jQuery(this).attr("checked","checked");
		}
	});
	<?php
	$d = getdate(time());
    $year=$d['year'];
    $month=$d['mon'];
    $day=$d['mday'];
	?>
	current_time = "<?php echo mktime(0,0,0,$month,$day,$year); ?>";
	if(day != current_time)
	{
		tab_i = 0;
	}
	else
	{
		tab_i = 99;
	}
	var url="<?php echo get_bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/ajaxchat_content.php";
	var xlurl="<?php echo get_bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/style/img/x1.gif";
	if(tab_ == 1)
	{
		if (day != current_time){
			jQuery("#chat_room_id").attr("disabled", true);
		}
		else{
			jQuery("#chat_room_id").attr("disabled", false);
		}
		textarea_enable(tab_,tab_i,current_sender_id,day);
		var operation = 'show_rec';
		jQuery.ajax({
			type: 'get',
			url: url+"?random="+(new Date()).getTime(),
			data: {operation : operation,day : day},
			beforeSend:function(){
				jQuery('#p-scroll-loader').hide();
				jQuery('#scroll-loader').hide();
				jQuery('#messageContent').html("<img src='"+loader+"'/>");
			},
			success:function(response){
				if(href.indexOf('#'))
				{
					var searchValue = href.substring(href.indexOf('#'));
				}
				//alert('show Rec');
				//var searchValue = document.location.hash == "" ? "#" : document.location.hash;
				json = eval('('+response+')');
				var output = '';
				if(json != null)
				{
					for(i=0;i < json.length;i++)
					{
						var rating_html = '';
						rating_num = (json[i].rating < 6) ? json[i].rating : 5 ;
						for(j=0;j < rating_num;j++)
						{
							rating_html += "<img src='"+xlurl+"' width='14' height='14' />";
						}
						output += "<li id='"+json[i].id+"' alt='"+json[i].room_id+"' style='background-color:#"+json[i].color+"'><div class='user'>"+json[i].icon+"<div class='text'>";
						output +="<a name='m_"+json[i].id+"'></a>";
						output += getUsername(json[i].sender_id,json[i].username,json[i].profiler,json[i].anonymous);
						output += "<span>"+json[i].text+"</span><div class='info'><p onmouseover='ajax_rating_count(event,this)' onmouseout='hidealt()' alt='"+json[i].rating+"' class='pic'>"+rating_html+"</p><p class='clock'>"+json[i].time+"</p>";
						if(current_sender_id != 0)
						{
							if(json[i].sender_id != current_sender_id )
							{
								output += "<p class='important'><a href='javascript:void(0);' onclick='addrating(this);return false;'>Important to me</a></p>";
							}
						}
						output += "</div></div><br class='clear' /></div></li>";
					}
				}
				else
				{
					output = '<li style="background:#fff;">'+nomessage_alert+'</li>';
				}
				jQuery('#messageContent').html(output);
				self.location.href = searchValue;
			}
		});
	}
	else if(tab_ == 2)
	{
		/*if (day != current_time){
			jQuery("#receiver_id").attr("disabled", true);
		}
		else{
			jQuery("#receiver_id").attr("disabled", false);
		}*/
		var receiver_id = jQuery("#receiver_id").attr("value");
		textarea_enable(tab_,tab_i,current_sender_id,day);
		var operation = 'show_rec_private';
		if (day != current_time){
			setReceiverEmpty();
		}
		jQuery.ajax({
			type: 'get',
			url: url+"?random="+(new Date()).getTime(),
			data: {operation : operation,day : day,receiver : receiver_id},
			beforeSend: function(){
				jQuery('#p-scroll-loader').hide();
				jQuery('#scroll-loader').hide();
				jQuery('#private_messageContent').html("<img src='"+loader+"'/>");
			},
			success: function(response){
				//alert('show Rec Private');
				json = eval('('+response+')');
				var output = '';
				if(json != null)
				{
					for(i=0;i < json.length;i++)
					{
						output += "<li id='"+json[i].id+"'><div class='user'><a href='#' onclick='reply(this.rel);return false;' rel='"+json[i].sender_id+"'>"+json[i].icon+"</a><div class='text'>";
						output += getUsername(json[i].sender_id,json[i].username,json[i].profiler,json[i].anonymous);
						output += "<span>"+json[i].text+"</span><div class='info'><p class='clock'>"+json[i].time+"</p>";
						if(json[i].sender_id != current_sender_id)
						{
						output += "<p class='important'><a href='javascript:void(0);' onclick='reply(this.rel);return false;' rel='"+json[i].sender_id+"'>reply to me</a></p>";
						}
						output += "</div></div><br class='clear' /></div></li>";
					}
				}
				else
				{
					output = '<li style="background:#fff;">'+nomessage_alert+'</li>';
				}
				jQuery('#private_messageContent').html(output);
			}
		});
	}
}
function setReceiverEmpty()
{
	jQuery("#receiver_id").attr('value','');
}
/*Ajax get the rating*/
function ajax_rating_count(e,obj)
{
    var evt = window.event || e;
    var rating = obj.getAttribute('alt');
    if(rating==0 || rating=='')
    {
        return false;
    }


    //alert(document.documentElement.scrollTop);
    if(checkBrowser()==2)
    {
        scroll_height=document.documentElement.scrollTop;
    }else{
        scroll_height=0;
    }

    //var o_rating=json[0].rating;
    document.getElementById("tip").innerHTML="Judged "+rating+" times as important.";
    document.getElementById("tip").style.visibility="visible";
    document.getElementById("tip").style.display = "";
    document.getElementById("tip").style.left = posx + "px";
    //document.getElementById("tip").style.left = (evt.pageX || evt.clientX) + "px";
    document.getElementById("tip").style.top = (posy + scroll_height)+"px";
    //document.getElementById("tip").style.top = ((evt.pageY || (evt.clientY)) + scroll_height)+"px";

    //+document.documentElement.scrollTop
}
/*js for float span*/
//window.onerror=new Function("return true");

function get_scroll_height(){
    var scrollPos;  if (typeof window.pageYOffset != 'undefined') {   scrollPos = window.pageYOffset;  }  else if (typeof document.compatMode != 'undefined'            && document.compatMode != 'BackCompat') {   scrollPos = document.documentElement.scrollTop;  }  else if (typeof document.body != 'undefined') {   scrollPos = document.body.scrollTop;  }

    return scrollPos;
}

function checkBrowser()
{
	if (window.navigator.userAgent.indexOf("MSIE")>=1)
	{
		return 2;
	}else if(window.navigator.userAgent.indexOf("Firefox")>=1)
	{
		return 4;
	}else{
		return 0;
	}
}
/*if (document.all)
{
        document.write("<div id=tip style='position:absolute; width:180px;line-height:14pt;  z-index:1;  background-color: #7D84B9; border: 1px solid gray; overflow: visible;visibility: hidden;font-size:7pt;padding:0;color:#ffffff;font-family:\'Lucida Grande\',Verdana,Arial,Sans-Serif'></div>");
}
else
{
	if (document.layers)
	{
		document.write("<layer id=tip visibility='hide' bgcolor='#7D84B9'></layer>");
	}
	else
	{
        document.write("<div id=tip style='position:absolute; width:180px;line-height:14pt;  z-index:1;  background-color: #7D84B9; border: 1px solid gray; overflow: visible;visibility: hidden;font-size:7pt;padding:0;color:#ffffff;font-family:\'Lucida Grande\',Verdana,Arial,Sans-Serif'></div>");
	}
}*/


function mouseMove(ev){
	 ev  = ev || window.event;
	 var mousePos = mouseCoords(ev);
	 posx = mousePos.x;
	 posy = mousePos.y;
}

function mouseCoords(ev){
	 if(ev.pageX || ev.pageY){
		  return {x:ev.pageX, y:ev.pageY};
	 }
	 return {
		  x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		  y:ev.clientY + document.body.scrollTop  - document.body.clientTop
	 };
}

document.onmousedown = mouseDown;
function mouseDown(ev){
	ev = ev || window.event;
	var target = ev.target || ev.srcElement;

	if(target.onmousedown || target.getAttribute('DragObj')){
		return false;
	}
}

function showalt(w){
	if (w=="")return;
	var dv = document.getElementById("tip");
	dv.innerHTML=w + "<br>";
	if (document.all)
	{
		dv.style.visibility="visible";
		dv.style.left=posx+10;       // event.x+10+document.body.scrollLeft;
		dv.style.pixelTop=posy+10;   // event.y+10+document.body.scrollTop;
	}
	else
	{
		if (document.layers)
		{
			dv.visibility="show";
			dv.left=posx+10;
			dv.top=posy+10;
		}
		else
		{
			dv.style.visibility="visible";
			dv.style.left= posx+10 ;
			dv.style.top=  posy+10 ;
		}
	}
}
function hidealt(){
	var dv = document.getElementById("tip");
	dv.style.innerHTML=""
	if (document.all)
	{
		dv.style.visibility="hidden";
	}
	else
	{
		if (document.layers)
		{
			dv.visibility="hide";
		}
		else
		{
			dv.style.visibility="hidden";
		}
	}
}

function ltrim(s){
return s.replace( /^\s*/, "");
}
//trim left space
function rtrim(s){
return s.replace( /\s*$/, "");
}
//trim right space
function trim(s){
return rtrim(ltrim(s));
}

/*
* validate if the channel is selected
*/
function validate_sel_channel()
{

    if(jQuery('#chat_room_id').val()=='')
    {
        jQuery('#alert_info').html('Please choose a Session.');
        return false;
    }

    return true;
}
/*
* validate if the user is selected
*/
function validate_sel_user()
{
    if(jQuery('#receiver_id').val()=='')
    {
        jQuery('#user_sel_info').html('Please choose a Participiant.');
        return false;
    }
    return true;
}


function lastPostFunc(){
    var r_day=document.getElementById("r_day").getAttribute("value");
    var r_page=document.getElementById("r_page").getAttribute("value");
    //alert(r_page);
    get_ajax_record(r_day,r_page)
}

function get_ajax_record(r_day,r_page)
{
    var current_time = <?php echo mktime(0,0,0,date("m"),date("d"),date("Y"));?>;
    var receiver_id = jQuery("#receiver_id").attr("value");
	var url="<?php echo get_bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/ajaxchat_content.php";
    var xlurl="<?php echo get_bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/style/img/x1.gif";
    var last_id=jQuery("#messageContent li:last-child").attr("id");
    var p_last_id=jQuery("#private_messageContent li:last-child").attr("id");

    if(tab_==1 && r_day!=current_time)
    {
		jQuery.ajax({
			type: 'get',
			url: url+"?random="+(new Date()).getTime(),
			data: {operation : 'show_rec',r_day : r_day,r_page:r_page},
			beforeSend: function(){
				jQuery('#scroll-loader').show();
			},
        	success: function(response){
				json = eval('('+response+')');
                var output='';
				if(json != null)
				{

					for(i=0;i < json.length;i++)
					{
                    var o_id=json[i].id;
                    if(jQuery('#messageContent').children('#'+o_id).html()==null)
                    {

						var rating_html = '';
						rating_num = (json[i].rating < 6) ? json[i].rating : 5 ;
						for(j=0;j < rating_num;j++)
						{
							rating_html += "<img src='"+xlurl+"' width='14' height='14' />";
						}
						output += "<li id='"+json[i].id+"' alt='"+json[i].room_id+"' style='background-color:#"+json[i].color+"'><div class='user'>"+json[i].icon+"<div class='text'>";
						output += getUsername(json[i].sender_id,json[i].username,json[i].profiler,json[i].anonymous);
						output += "<span>"+json[i].text+"</span><div class='info'><p onmouseover='ajax_rating_count(event,this)' onmouseout='hidealt()' alt='"+json[i].rating+"' class='pic'>"+rating_html+"</p><p class='clock'>"+json[i].time+"</p>";
						if(current_sender_id != 0)
						{
							if(json[i].sender_id != current_sender_id )
							{
								output += "<p class='important'><a href='javascript:void(0);' onclick='addrating(this);return false;'>Important to me</a></p>";
							}
						}

						output += "</div></div><br class='clear' /></div></li>";
                    }
					}
				}
                if(output!='')
                {
                    jQuery('#messageContent').append(output);
                    document.getElementById("r_page").setAttribute("value",Number(document.getElementById("r_page").getAttribute("value"))+1);
                }
				jQuery('#scroll-loader').hide();
        	}
        });
    }else if(tab_==1 && r_day==current_time)
    {
		jQuery.ajax({
			type: 'get',
			url: url+"?random="+(new Date()).getTime(),
			data: {operation : 'current_chat',r_day : r_day,r_page:r_page,last_id:last_id},
			beforeSend: function(){
				jQuery('#scroll-loader').show();
			},
         	success: function(response){
				json = eval('('+response+')');
                var output='';
                var dis='';
				if(json != null)
				{
					for(i=0;i < json.length;i++)
					{
                    var o_id=json[i].id;
                    if(jQuery('#messageContent').children('#'+o_id).html()==null)
                    {
						var rating_html = '';
						rating_num = (json[i].rating < 6) ? json[i].rating : 5 ;
						for(j=0;j < rating_num;j++)
						{
							rating_html += "<img src='"+xlurl+"' width='14' height='14' />";
						}
                        if(jQuery("input[id=room_"+json[i].room_id+"]").attr("checked")!=true)
                        {
                            dis="none";
                        }else
                        {
                            dis='';
                        }


						output += "<li id='"+json[i].id+"' alt='"+json[i].room_id+"' style='background-color:#"+json[i].color+";display:"+dis+"'><div class='user'>"+json[i].icon+"<div class='text'>";
						output += getUsername(json[i].sender_id,json[i].username,json[i].profiler,json[i].anonymous);
						output += "<span>"+json[i].text+"</span><div class='info'><p onmouseover='ajax_rating_count(event,this)' onmouseout='hidealt()' alt='"+json[i].rating+"' class='pic'>"+rating_html+"</p><p class='clock'>"+json[i].time+"</p>";
						if(current_sender_id != 0)
						{
							if(json[i].sender_id != current_sender_id)
							{
								output += "<p class='important'><a href='javascript:void(0);' onclick='addrating(this);return false;'>Important to me</a></p>";
							}
						}
						output += "</div></div><br class='clear' /></div></li>";
					}
                    }
				}
                if(output!='')
                {
                    jQuery('#messageContent').append(output);
                    document.getElementById("r_page").setAttribute("value",Number(document.getElementById("r_page").getAttribute("value"))+1);
                }
				jQuery('#scroll-loader').hide();
			}
        });
    }
    else if(tab_==2&& r_day!=current_time)
    {

		jQuery.ajax({
			type: 'get',
			url: url+"?random="+(new Date()).getTime(),
			data: {operation :'show_rec_private',r_day : r_day,receiver : receiver_id,r_page:r_page},
			beforeSend: function(){
				jQuery('#p-scroll-loader').show();
			},
         	success: function(response){

				json = eval('('+response+')');
                var output='';
				if(json != null)
				{
					for(i=0;i < json.length;i++)
					{
                    var o_id=json[i].id;
                    if(jQuery('#private_messageContent').children('#'+o_id).html()==null)
                    {
						output += "<li id='"+json[i].id+"'><div class='user'><a href='#' onclick='reply(this.rel);return false;' rel='"+json[i].sender_id+"'>"+json[i].icon+"</a><div class='text'>";
						output += getUsername(json[i].sender_id,json[i].username,json[i].profiler,json[i].anonymous);
						output += "<span>"+json[i].text+"</span><div class='info'><p class='clock'>"+json[i].time+"</p>";
						if(json[i].sender_id != current_sender_id)
						{
						output += "<p class='important'><a href='javascript:void(0);' onclick='reply(this.rel);return false;' rel='"+json[i].sender_id+"'>reply to me</a></p>";
						}
						output += "</div></div><br class='clear' /></div></li>";
                    }
					}
				}
                if(output!='')
                {
                jQuery('#private_messageContent').append(output);
                document.getElementById("r_page").setAttribute("value",Number(document.getElementById("r_page").getAttribute("value"))+1);
                }
				jQuery('#p-scroll-loader').hide();
			}
        });
    }
    else if(tab_==2 && receiver_id!='' && r_day==current_time)
    {
		jQuery.ajax({
			type: 'get',
			url: url+"?random="+(new Date()).getTime(),
			data: {operation :'private_current',r_day : r_day,receiver : receiver_id,r_page:r_page,p_last_id:p_last_id},
			beforeSend: function(){
				jQuery('#p-scroll-loader').show();
			},
         	success: function(response){
				json = eval('('+response+')');
                var output='';
				if(json != null)
				{
					for(i=0;i < json.length;i++)
					{
                    var o_id=json[i].id;
                    if(jQuery('#private_messageContent').children('#'+o_id).html()==null)
                    {
						output += "<li id='"+json[i].id+"'><div class='user'><a href='#' onclick='reply(this.rel);return false;' rel='"+json[i].sender_id+"'>"+json[i].icon+"</a><div class='text'>";
						output += getUsername(json[i].sender_id,json[i].username,json[i].profiler,json[i].anonymous);
						output += "<span>"+json[i].text+"</span><div class='info'><p class='clock'>"+json[i].time+"</p>";
						if(json[i].sender_id != current_sender_id)
						{
						output += "<p class='important'><a href='javascript:void(0);' onclick='reply(this.rel);return false;' rel='"+json[i].sender_id+"'>reply to me</a></p>";
						}
						output += "</div></div><br class='clear' /></div></li>";
                    }
					}
				}
                if(output!='')
                {
                jQuery('#private_messageContent').append(output);
      document.getElementById("r_page").setAttribute("value",Number(document.getElementById("r_page").getAttribute("value"))+1);
                }
				jQuery('#p-scroll-loader').hide();
			}
        });
    }
}

